package com.example.task2u;

import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.Toast;
import android.widget.TabHost.TabSpec;


public class MainActivity extends TabActivity {

	TabHost th;
	
    @SuppressWarnings("deprecation")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
    
        th = (TabHost)findViewById(android.R.id.tabhost);
        Intent i1 = new Intent(this, Hoje.class);
    	i1.putExtra("new_variable", "0");

    	Intent i2 = new Intent(this, Amanha.class);
    	i2.putExtra("new_variable", "1");
    	
        Intent i3 = new Intent(this, Pendente.class);
        i3.putExtra("new_variable","2");
        
        TabSpec spec1 = th.newTabSpec("hoje"); //tabhost object
        spec1.setContent(i1);
        spec1.setIndicator("Hoje"); //set title
       
        th.addTab(spec1);
    
        TabSpec spec2 = th.newTabSpec("amanha"); //tabhost object
        spec2.setContent(i2);
        spec2.setIndicator("Amanha"); //set title
       
        th.addTab(spec2);
	    
	    TabSpec spec3 = th.newTabSpec("pendente"); //tabhost object
	    spec3.setContent(i3);
	    spec3.setIndicator("Pendente"); //set title
	   
	    th.addTab(spec3);
	    
	    	    
	    final Button button = (Button) findViewById(R.id.adicionaTarefa);
        button.setOnClickListener(new OnClickListener() {
            public void onClick(View v) {
                Intent i4 = new Intent(MainActivity.this, AdicionarTarefa.class);
                if(th.getCurrentTab() == 0)
                {
                	Log.d("passei neste", "1o");
                	i4.putExtra("new_variable", 0);
                }else if(th.getCurrentTab() == 1){
                	Log.d("passei neste", "2o");
                	i4.putExtra("new_variable", 1);
                }else if(th.getCurrentTab() == 2){                
                Log.d("passei neste", "3o");
                i4.putExtra("new_variable", 2);
                }
   				startActivity(i4);
   				//finish();
            }
        });
  

    }
}
